package com.curd.tk.config.swagger;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.RequestHandler;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


@Configuration
@EnableSwagger2
@EnableKnife4j
public class SwaggerConfig {


    @Bean(value = "tk")
    public Docket tk() {
        Predicate<RequestHandler> model = RequestHandlerSelectors.basePackage("com.curd.tk");
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(true)
                .apiInfo(apiInfo())
                .groupName("TK")
                .select()
                .apis(model)
                .paths(Predicates.not(PathSelectors.regex("/error.*")))
                .build();
    }






    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("CURD API")
//                .licenseUrl(url + "/doc.html")
//                .license(email)
//                .contact(new Contact(author, url, email))
                .description("Cloud SYSTEM 开发栈")
//                .version(version)
                .title("TK CURD API 接口文档")
                .build();
    }
}
